#include <QRegExpValidator>
#include "greychange.h"
#include "ui_greychange.h"

GreyChange::GreyChange(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GreyChange)
{
    ui->setupUi(this);
    setWindowFlags(Qt::Tool| Qt::WindowStaysOnTopHint);
    ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("0(\\.\\d+)?|1\\.0")));
}

GreyChange::~GreyChange()
{
    delete ui;
}

void GreyChange::on_horizontalSlider_sliderMoved(int position)
{
    float num=(float)position/10;
    QString str = QString::number(num ,'f',1);
    ui->lineEdit->setText(str);
}

void GreyChange::on_horizontalSlider_valueChanged(int value)
{
    float num=(float)value/10;
    QString str = QString::number(num ,'f',1);
    ui->lineEdit->setText(str);
}

void GreyChange::on_pushButton_2_clicked()
{
    this->close();
}

void GreyChange::on_pushButton_clicked()
{
    sendData(ui->lineEdit->text().toFloat());
    this->close();
}
